package com.zrkj.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zrkj.entity.Zruser;
import com.zrkj.entity.vo.Result;
import com.zrkj.service.IZruserService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
/**
 * @author : 司总
 * @className : ZruserController
 * @package: com.zrkj.controller
 * @description : 用户表 前端控制器
 * @date :  2023-11-23
 */
@RestController
@RequestMapping(value = "/zruser")
@Api(tags = "用户表")
public class ZruserController {
private final IZruserService izruserService;

public ZruserController(IZruserService izruserService){
        this.izruserService=izruserService;
        }

/**
 * 添加
 *
 * @param zruser
 * @return
 */
@PostMapping("/add")
public Result<String> add(@RequestBody Zruser zruser){
        return izruserService.add(zruser);
        }

/**
 * 更新
 *
 * @param zruser
 * @return
 */
@PutMapping(value = "/update")
public Result<Boolean> update(@RequestBody Zruser zruser){
        return izruserService.update(zruser);
        }

/**
 * 删除
 *
 * @param ids
 * @return
 */
@DeleteMapping(value = "/delete")
public Result<Boolean> delete(@RequestParam(value = "ids") String ids){
        String[]idsArray=ids.split(",");
        List<String> idList=new ArrayList<>();
        for(String id:idsArray){
        idList.add(id);
        }
        return izruserService.delete(idList);
        }

/**
 * 查询详情
 *
 * @param id
 * @return
 */
@GetMapping(value = "/getById/{id}")
public Result<Zruser> getById(@PathVariable(value = "id") String id){
        return izruserService.getById(id);
        }

/**
 * 查询列表
 *
 * @param zruser
 * @return
 */
@PostMapping(value = "/queryList")
public Result<List<Zruser>>queryList(@RequestBody Zruser zruser){
        return izruserService.queryList(zruser);
        }

/**
 * 查询分页列表
 *
 * @param zruser
 * @return
 */
@PostMapping(value = "/queryPageList")
public Result<IPage<Zruser>>queryPageList(@RequestBody Zruser zruser){
        return izruserService.queryPageList(zruser.getPage(), zruser);
        }
        }
